﻿		/*currentpage:当前页*/
		/*totalpage:总页数*/
		/*mode:分页条显示的页列表数*/
		/*method:翻页调用的函数名*/
		function nav(currentpage,totalpage,mode,method){
	         var iStart = mode * (parseInt((currentpage-1) / mode))+ 1;
	         var iEnd = (iStart + mode) > totalpage ? totalpage: iStart + mode-1;
	         var preNavigator=currentpage<=1?1:currentpage-1;
	         var nextNavigator=parseInt(currentpage) + 1;
	         nextNavigator=nextNavigator>totalpage?1:nextNavigator;
	  
	        var str="";//"<a href='javascript:pagination(1)' class='lgray'>首页</a>\n";
			if(currentpage==1){
				 str+="<span style='color:#ccc;'><<上一页</span>\n";
			}else{
				str+="<a href='javascript:"+method+"("+preNavigator+")' class='lgray'><<上一页</a>\n";
			}
			var temp =iStart;
			for( var i = 0;i<mode;i++){
			  	temp = iStart+i;
	            if(currentpage==iStart+i){
					str+="<a href='javascript:"+method+"("+temp+")' class='sed'>"+temp+"</a>\n";
				}else{
					str+="<a href='javascript:"+method+"("+temp+")' class='lgray' >"+temp+"</a>\n";
				}
				if((iStart+i)>=iEnd){
					  if(currentpage!=totalpage&&totalpage>mode){
						str+="<span>...</span>";
					  }
					  break;
				}
			}				
			if(currentpage>=totalpage)
			{
				if(currentpage==totalpage){						
					 str+="<span style='color:#ccc;'>下一页</span>\n";
				}else{
	            	str+="<a href='javascript:"+method+"("+nextNavigator+")' class='lgray'>下一页>></a>\n";
				}				
			}else{				
				str+="<a href='javascript:"+method+"("+nextNavigator+")' class='lgray'>下一页>></a>\n";
			}
			//str+="<a href='javascript:pagination("+totalpage+")' class='lgray'>末页</a>";
			str+="<span>&nbsp;<label>共"+totalpage+"页,到第</label><input type=\"text\" style=\"text-align:center; width:30px;\" id=\"toPage_input\" size=\"3\" value=\"1\"/><label>页&nbsp;</label><a  href='###' onclick=\"toPage("+totalpage+")\" class='lgray'>确定</></span>\n";
			document.write(str);
		}
		
		function toPage(totalPage){
			var page=document.getElementById('toPage_input').value;
			if(page!=undefined&&IsNum(page)){
				if(parseInt(page)>=1&&parseInt(page)<=totalPage){
					pagination(page);
				}
			}
		}
		function IsNum(num){
			  var reNum=/^\d*$/;
			  return(reNum.test(num));
		}